<?php
/**
 * 就诊人管理控制器:后台
 * Created by PhpStorm.
 * User: zxj
 * Date: 17/5/1
 * Time: 上午9:11
 */
namespace App\Http\Controllers\Admin;

use App\Models\Member;

class MemberController extends BaseController
{

    public function __construct(Member $member)
    {
        parent::__construct();
        $this->member = $member;
    }

    /**
     *后台:就诊人管理首页列表
     */
    public function getIndex(){

        $data = $this->member->getMemberList2(request());
        return view('admin.member.index',compact('data'));


    }

    //后台:显示医师就诊人首页
    public function getEditMemberList(){

        //$request=request('id');
        //dd($request);
        if(request()){

            $data = $this->member->getMemberById(request());
            //dd($data);
            return view('admin.member.edit',compact('data'));

        }


    }

    /**
     * @return \Illuminate\Http\JsonResponse
     * 获取就诊人列表
     */

    public function getList(){
        $res = $this->member->getMemberList2(request());
        return ajax_return($res);
    }

    //根据id获取就诊人信息
    public function getMemberInfo(){

        $res = $this->member->getMemberById(request());
        return ajax_return($res);

    }

    // 显示编辑就诊人页面
    public function getEditMember()
    {
        if(request()){

            $data = $this->member->getMemberById(request());
//            dd($data);
            return view('admin.member.edit',compact('data'));

        }
    }

    //处理编辑就诊人请求
    public function postEditMember(){
              $res = $this->member->editMember(request());
        //return ajax_return($res);
        return redirect(url('center/member/index'));
    }

    //处理删除就诊人请求
    public function getDelMember(){
        $where['id'] = request('id');
        $res = $this->member->del($where);
        if($res){

            $res = ['state'=>1,'msg'=>'ok'];

        }else{

            $res = ['state'=>0,'msg'=>'fail'];

        }
        return ajax_return($res);
        //return redirect(Url('center/member/index'));
    }
    
}